package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.sys.dao.ShopOrderDao;
import io.renren.modules.sys.entity.ShopOrderEntity;
import io.renren.modules.sys.service.MerchantOrderService;
import io.renren.modules.sys.service.ShopOrderService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("merchantOrderService")
public class MerchantOrderServiceImpl extends ServiceImpl<ShopOrderDao, ShopOrderEntity> implements MerchantOrderService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String status = (String)params.get("status");
        String orderSn = (String)params.get("orderSn");
        String userId = (String)params.get("userId");
        String merchantid = (String)params.get("merchantid");
        IPage<ShopOrderEntity> page = this.page(
                new Query<ShopOrderEntity>().getPage(params),
                new QueryWrapper<ShopOrderEntity>()
                        .eq(StringUtils.isNotBlank(status), "ORDER_STATUS", status)
                        .like(StringUtils.isNotBlank(orderSn), "ORDER_SN", orderSn)
                        .like(StringUtils.isNotBlank(userId), "USER_ID", userId)
                        .eq(StringUtils.isNotBlank(merchantid), "merchantid", merchantid)
        );

        return new PageUtils(page);
    }

    @Override
    public List<ShopOrderEntity> queryList(){
        return baseMapper.queryList();
    }
}
